/* 移动端优化样式 */

/* 安全区域适配 */
:root {
  --safe-area-inset-top: env(safe-area-inset-top);
  --safe-area-inset-right: env(safe-area-inset-right);
  --safe-area-inset-bottom: env(safe-area-inset-bottom);
  --safe-area-inset-left: env(safe-area-inset-left);
  
  /* 移动端主题色 */
  --primary-color: #007bff;
  --primary-dark: #0056b3;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --info-color: #17a2b8;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  
  /* 移动端间距 */
  --mobile-padding: 1rem;
  --mobile-margin: 0.75rem;
  --mobile-border-radius: 12px;
  
  /* 移动端字体 */
  --mobile-font-size-xs: 0.75rem;
  --mobile-font-size-sm: 0.875rem;
  --mobile-font-size-base: 1rem;
  --mobile-font-size-lg: 1.125rem;
  --mobile-font-size-xl: 1.25rem;
  
  /* 移动端阴影 */
  --mobile-shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --mobile-shadow: 0 4px 8px rgba(0,0,0,0.15);
  --mobile-shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
}

/* 全局移动端优化 */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  color: #212529;
  background-color: #f8f9fa;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-area-inset-top);
  padding-right: var(--safe-area-inset-right);
  padding-bottom: var(--safe-area-inset-bottom);
  padding-left: var(--safe-area-inset-left);
}

/* 主要内容区域 */
.main-content {
  flex: 1;
  padding: var(--mobile-padding);
  max-width: 100%;
  overflow-x: hidden;
}

/* 键盘弹出时的样式调整 */
body.keyboard-open {
  height: auto;
}

body.keyboard-open #app {
  height: auto;
  min-height: 100vh;
}

/* 触摸优化 */
.btn, button, [role="button"] {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* 输入框优化 */
input, textarea, select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 8px;
  font-size: 16px; /* 防止iOS缩放 */
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* 表格响应式优化 */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

/* 模态框移动端优化 */
.modal {
  padding: 0 !important;
}

.modal-dialog {
  margin: 0;
  height: 100vh;
  max-height: none;
  max-width: none;
  width: 100%;
}

.modal-content {
  height: 100vh;
  border: none;
  border-radius: 0;
}

.modal-header {
  padding-top: calc(var(--safe-area-inset-top) + 1rem);
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
}

.modal-footer {
  padding-bottom: calc(var(--safe-area-inset-bottom) + 1rem);
  border-top: 1px solid #dee2e6;
  position: sticky;
  bottom: 0;
  background: white;
  z-index: 1;
}

/* 登录页面移动端优化 */
.login-container {
  padding: var(--safe-area-inset-top) var(--safe-area-inset-right) var(--safe-area-inset-bottom) var(--safe-area-inset-left);
  min-height: 100vh;
}

.login-card {
  margin: 0 1rem;
  max-width: none;
  width: calc(100% - 2rem);
}

/* 导航栏移动端优化 */
.navbar {
  padding-top: var(--safe-area-inset-top);
  padding-left: calc(var(--safe-area-inset-left) + 1rem);
  padding-right: calc(var(--safe-area-inset-right) + 1rem);
}

/* 卡片组件移动端优化 */
.card {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
}

.card-header {
  border-radius: 12px 12px 0 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #333;
  border: 1px solid #dee2e6;
  text-shadow: none;
}

/* 按钮移动端优化 */
.btn {
  min-height: 44px; /* iOS推荐的最小触摸目标 */
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

/* 表单控件移动端优化 */
.form-control {
  min-height: 44px;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 2px solid #e9ecef;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* 进度条优化 */
.progress {
  height: 8px;
  border-radius: 4px;
  background-color: #e9ecef;
}

.progress-bar {
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* 徽章优化 */
.badge {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-weight: 500;
}

/* 警告框优化 */
.alert {
  border-radius: 8px;
  border: none;
  padding: 1rem;
  margin-bottom: 1rem;
}

/* 列表组优化 */
.list-group-item {
  border-radius: 8px;
  border: 1px solid #e9ecef;
  margin-bottom: 0.5rem;
  padding: 1rem;
}

/* 工具提示优化 */
.tooltip {
  font-size: 14px;
}

/* 下拉菜单优化 */
.dropdown-menu {
  border-radius: 8px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.5rem 0;
}

.dropdown-item {
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: #f8f9fa;
}

/* 分页优化 */
.pagination {
  margin: 0;
}

.page-link {
  min-height: 44px;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0 0.25rem;
  border: 1px solid #dee2e6;
}

/* 加载动画优化 */
.spinner-border {
  width: 2rem;
  height: 2rem;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

/* 网络状态提示 */
.network-status {
  position: fixed;
  top: var(--safe-area-inset-top);
  left: 0;
  right: 0;
  background: #dc3545;
  color: white;
  text-align: center;
  padding: 0.5rem;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.network-status.show {
  transform: translateY(0);
}

/* 滚动条优化 */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* 媒体查询 - 小屏幕优化 */
@media (max-width: 576px) {
  .container, .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .table-responsive {
    font-size: 0.875rem;
  }
  
  .btn-group .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .modal-dialog {
    margin: 0;
  }
  
  .card {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
  }
}

/* 横屏优化 */
@media (orientation: landscape) and (max-height: 500px) {
  .login-container {
    padding: 1rem;
  }
  
  .login-card {
    padding: 2rem;
  }
  
  .modal-dialog {
    height: 100vh;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  :root {
    --bs-body-bg: #121212;
    --bs-body-color: #ffffff;
    --bs-border-color: #333333;
  }
  
  .card {
    background-color: #1e1e1e;
    border-color: #333333;
  }
  
  .modal-content {
    background-color: #1e1e1e;
    color: #ffffff;
  }
  
  .form-control {
    background-color: #2d2d2d;
    border-color: #444444;
    color: #ffffff;
  }
  
  .form-control:focus {
    background-color: #2d2d2d;
    border-color: #0d6efd;
    color: #ffffff;
  }
}